<?
require("../../common/init.php");
require("author.php");

$sales_order=new DB(Tsales_order,$conn);
$sales_order_detail=new DB(Tsales_order_detail,$conn);

$title=ROOT_DASHBOARD;
$url='dashboard';



//5 most view products
$where=array();
$where[]=array('name'=>'hit_count','val'=>0,'opn'=>'>');
$most_view=$product->get_rows_advanced(5, $where, 'hit_count', 'desc');


//5 most sold products
$where=array();
$where[]=array('name'=>'sold_quantity','val'=>0,'opn'=>'>');
$most_sold=$product->get_rows_advanced(5, $where, 'sold_quantity', 'desc');

//5 latest paid orders
//2 is paid, 3 is pending to ship
$where=array();
$where[]=array('name'=>'order_status','val'=>array(2,3),'opn'=>'in');
$lastest_orders=$sales_order->get_rows_advanced(5, $where, 'paid_time', 'desc');

//5 latest paid orders
//2 is paid, 3 is pending to ship
$most_reviewed=$product_review->query_to_array("select product_id, count(*) cnt from product_review group by product_id order by cnt desc limit 5");

//5 most searched keywords
$most_searched_keywords=$keyword->get_rows(5, '', '', 'hit_count', 'desc');

// view 加载视图
require ROOTVIEW.$url.'.php';

// end dashboard.php